package com.coderlin.controller;

import com.coderlin.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * <Description> <br>
 *
 * @author Coder_Lin<br>
 * @version 1.0<br>
 * @taskId: <br>
 * @createDate 2021/07/22 15:53 <br>
 * @see com.coderlin.controller <br>
 */
@Controller
public class AccountController {

    @Autowired
    private AccountService accountService;

    @RequestMapping(value = "/login")
    public String login(String userName, String userPwd, Model model, HttpSession session){
        boolean login = accountService.login(userName, userPwd);

        if (false == login){
            model.addAttribute("loginFail", "用户名或者密码错误");
            return "index";
        }else{
            session.setAttribute("currentUserName",userName);
            return "waterMainMenu";
        }
    }
}
